﻿#include<iostream>
#include<vector>
#include"vector.h"
#include<list>

using namespace std;

namespace dan
{
	template<class Container>
	void Print(const Container& v)
	{
		for (auto e : v)
		{
			cout << e << ' ';
		}

		cout << endl;
	}

	void test01()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);

		/*v1.pop_back();
		v1.pop_back();
		v1.pop_back();
		v1.pop_back();*/


		//	cout << v1[9];
		Print(v1);

		v1.insert(v1.begin(), 6);
		//v1.insert(v1.begin()+2, 9);
		Print(v1);

		auto it = find(v1.begin(), v1.end(), 3);
		if (it != v1.end())
		{
			v1.insert(it, 0);
			//it失效
			//insert之后认为it失效不能继续使用
			//*it = 1000;
		}
		Print(v1);
	}

	void test02()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);

		//删除偶数
		auto it = v1.begin();
		while (it != v1.end())
		{
			if (*it % 2 == 0)
			{
				//重新赋值更新迭代器
				//erase返回值是指向被删除数据的下一个数据的迭代器
				it=v1.erase(it);
			}
			else 
			{
				it++;
			}
		}

		Print(v1);

		/*int n();
		int j = int();
		int m(10);
		int k = int(10);*/

	}
	void test03()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		
		v1.resize(10, 1);
		Print(v1);
		v1.resize(5);
		Print(v1);
		v1.resize(20);
		Print(v1);
		
		vector<int>v0;
		vector<int> v2(v0);
		Print(v2);
	}

	void test04()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);

		//vector<int>v(1, 2, 3);
		vector<int>v{ 1, 2, 3 };
		
		list<int>l{ 6,7,8,9 };
		vector<int> v0{l.begin()++, l.end()--};
		Print(v0);

		//cout << &v0<<endl;
		v0 = v1;
		Print(v0);
		cout << v0.size()<< v1.size()<< endl;
		cout << v0.capacity() << v1.capacity() << endl;
	}

}


int main()
{
	dan::test04();
	return 0;
}
